package cn.itsource.basic.controller;

import cn.itsource.basic.service.IVerificationCodeService;
import cn.itsource.basic.util.AjaxResult;
import cn.itsource.user.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/Verification")
public class VerificationCodeController {

    @Autowired
    private IVerificationCodeService service;

   @PostMapping("/code")
    public AjaxResult shendcode(@RequestBody User user){
        try {
            System.out.println(user.getPhone());
            service.sendVerificationCode(user.getPhone());
            return new AjaxResult();
        } catch (Exception e) {
            e.printStackTrace();
            return  new AjaxResult(false,e.getMessage());
        }
    }

    @PostMapping("/sendlogin")
    public AjaxResult shendcodelogin(@RequestBody User user){
        try {
            System.out.println(user.getPhone());
            service.sendbandVerificationCode(user.getPhone());
            return new AjaxResult();
        } catch (Exception e) {
            e.printStackTrace();
            return  new AjaxResult(false,e.getMessage());
        }
    }



}
